package com.huajin.springcodetest.aop;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.huajin.springcodetest.transactional.UserService;

@Aspect
@Component
public class UserAspect {
	
	@Autowired
	private UserService userService;
	
	@AfterReturning(pointcut = "execution(* com.huajin.springcodetest.transactional.UserService.addUser(..))", returning = "returnValue")
	public void addUser(Object returnValue) {
		Integer id = (Integer) returnValue;
		System.out.println(userService.getByIdForUpdate(id).getLoginName());
	}

}
